package com.by.course;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.net.InetAddress;

@Slf4j
@MapperScan("com.by.course.mapper")
@ServletComponentScan("com.by.course")
@SpringBootApplication
@EnableScheduling
@EnableCaching
public class CourseApplication {

    public static void main(String[] args) throws Exception {
        ApplicationContext context = SpringApplication.run(CourseApplication.class, args);
        Environment env = context.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path");
        String start =
                "\n----------------------------------------------------------\n\t" + " 启动成功! \n\t";
        String site = "项目地址: \thttps://" + ip + ":" + port + "\n\t";
        String swaggerFile = "swagger 文档地址: \thttps://" + ip + ":" + port + contextPath + "/doc.html\n\t";
        log.info(start + site + swaggerFile);
    }
}
